#include<iostream>

#include"BinarySearchTree.hpp"

using namespace std;

void test1(){
  BinarySearchTree<int> t1;
  //测试二叉搜索树的数据插入

  int a[] = {8, 3, 1, 10, 6, 4, 7, 14, 13};
  for(auto it:a){
    t1.Insert(it);
  }

  //测试二叉搜索树的中序遍历
  t1.InOrder();
  
  //测试二叉搜索树的查找
  
  cout<<t1.Find(10)<<endl;
  cout<<t1.Find(26)<<endl;

}


void test2(){
  BinarySearchTree<int> t1;
  //测试二叉搜索树的数据插入

  int a[] = {8, 3, 1, 10, 6, 4, 7, 14, 13};
  for(auto it:a){
    t1.Insert(it);
  }

  //测试二叉搜索树的中序遍历
 // t1.InOrder();
  
  t1.InOrder();
  t1.Erase(10);
  t1.InOrder();
  t1.Erase(14);
  t1.InOrder();
  t1.Erase(13);
  t1.InOrder();
  t1.Erase(8);
  t1.InOrder();

//  t1.InOrder();
//
//
////  t1.Insert(0);
////  t1.Insert(16);
//
//  t1.Erase(6);
//  t1.InOrder();

}

void test3(){
  BinarySearchTree<int> t1;
  //测试二叉搜索树的数据插入

  int a[] = {8, 3, 1, 10, 6, 4, 7, 14, 13};
  for(auto it:a){
    t1.InsertR(it);
  }

  t1.InOrder();
  t1.EraseR(13);

  t1.InOrder();
  t1.EraseR(14);

  t1.InOrder();
  t1.EraseR(10);

  t1.InOrder();
  t1.EraseR(8);

  t1.InOrder();
  t1.EraseR(3);

  t1.InOrder();
  t1.EraseR(4);

  t1.InOrder();
  t1.EraseR(6);
  
  t1.InOrder();
  t1.EraseR(1);
  
  t1.InOrder();
  t1.EraseR(7);

  t1.EraseR(10);
  t1.InOrder();

}



void test4(){
  BinarySearchTree<int> t1;
  //测试二叉搜索树的数据插入

  int a[] = {8, 3, 1, 10, 6, 4, 7, 14, 13};
  for(auto it:a){
    t1.InsertR(it);
  }

  t1.InOrder();

  BinarySearchTree<int>t2(t1);
  t2.InOrder();

  BinarySearchTree<int> t3;
  t3=t1;
  t3.Erase(1);
  t3.InOrder();

}



int main()
{
 //test1();
 
  //test2();
  
  //test3();
  
  test4();


  return 0;
}
